<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>       
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<title>我的工作台</title>
<%@ include file="/WEB-INF/jsp/common/inc.jsp" %>
<script type="text/javascript" src="${_resources}datepicker/WdatePicker.js"></script>
	
<script  type="text/javascript">
	var jumpWork = "${jumpWork}";
	function toMessageDetail(url,messageId,parentModelName){
		if(parentModelName == "测试管理"){
			if(url.indexOf("/testCase/isExistCase") != '-1'){
				$.ajax({
			        type: "post",
			        dataType: "json",
			        url: '${_baseUrl}/index/updateMessageStatus',
			        data: {messageId:messageId},
			        success: function (data) {
			        	if("1" == data.code){
			        		$.ajax({
								url : url,
								type : 'post', //数据发送方式 
								dataType : 'json', //接受数据格式 
								async : false,
								success : function(json) {
									if(json.code == '1'){
										var testCaseId = json.data;
										var testRoundId = json.message;
										layerIndex1 = parent.layer.open({
											 type: 2,
											 title: '待办事项',
											 area: ['1000px', '350px'],
											 fixed: false, //不固定
											 maxmin: true,
											 shim: true,
											 content:"${_baseUrl}/testCase/toTestCaseAudit?testCaseId="+testCaseId+"&testRoundId="+testRoundId+"&rand="+Math.random()
										});
										location.reload();
										layer.full(layerIndex1);
										
									//	refreshTable();
										
									}else{
										var projectId = json.data;
										parent.closeAndSkip(parentModelName,"${_baseUrl}/testProcess/showTestProcessDemandMenu?projectId="+projectId,messageId);
									}
								},
								error : function() {
									layer.msg("系统错误,请联系管理员");
								}
							});	
			        	
			        	}
			        },
			        error:function(json){
						layer.msg("系统错误,请联系管理员");
					}
			    });
			}else if(url.indexOf("/editProduct/synergyWrite") != '-1'){
				$.ajax({
					url : '${_baseUrl}/workbench/updateNeedHandleEvent?id='+messageId,
					type : 'post', //数据发送方式 
					dataType : 'json', //接受数据格式 
					async : false,
					success : function(json) {
						if(json.code == '0'){
							layerIndex2 = parent.layer.open({
								 type: 2,
								 title: '待办事项',
								 area: ['1000px', '350px'],
								 fixed: false, //不固定
								 maxmin: true,
								 shim: true,
								 content:url+"&rand="+Math.random()
							});
							location.reload();
							layer.full(layerIndex2);
							//refreshTable();
						}
					},
					error : function() {
						layer.msg("系统错误,请联系管理员");
					}
			});
			layer.full(layerIndex2);
			}else{
// 				parent.parent.closeAndSkip(parentModelName,url,messageId);
				$.ajax({
					url : '${_baseUrl}/workbench/updateNeedHandleEvent?id='+messageId,
					type : 'post', //数据发送方式 
					dataType : 'json', //接受数据格式 
					async : false,
					success : function(json) {
						if(json.code == '0'){
							layerIndex2 = parent.layer.open({
								 type: 2,
								 title: '待办事项',
								 area: ['1000px', '350px'],
								 fixed: false, //不固定
								 maxmin: true,
								 shim: true,
								 content:url+"&rand="+Math.random()
							});
							location.reload();
							layer.full(layerIndex2);
							
							//refreshTable();
							 
						}
					},
					error : function() {
						layer.msg("系统错误,请联系管理员");
					}
			});
				layer.full(layerIndex2);
			}
		}else if(parentModelName == 'KT项目管理' || parentModelName == 'KD项目管理' || parentModelName == '需求管理'){
			sigh(messageId);
			parent.skipModule(parentModelName,"");
		}else{
			$.ajax({
				url : '${_baseUrl}/workbench/updateNeedHandleEvent?id='+messageId,
				type : 'post', //数据发送方式 
				dataType : 'json', //接受数据格式 
				async : false,
				success : function(json) {
					if(json.code == '0'){
						layerIndex1 = parent.layer.open({
							 type: 2,
							 title: '待办事项',
							 area: ['1000px', '350px'],
							 fixed: false, //不固定
							 maxmin: true,
							 shim: true,
							 content:url+"&rand="+Math.random()
						});
						location.reload();
						layer.full(layerIndex1);
						//refreshTable();
						
					}
				},
				error : function() {
					layer.msg("系统错误,请联系管理员");
				}
			});	
		}
		
	}
function onclickLastMenu(){
  layer.closeAll();
}

function closeWin(){
	layer.closeAll();
}

function refreshTable(){

}
function closeWin1(layerIndex){
	layer.close(layerIndex);
}
function refreshTree(num,id){
}
function sigh(messageId){
	$.ajax({
		url : '${_baseUrl}/workbench/updateNeedHandleEvent?id='+messageId,
		type : 'post', //数据发送方式 
		dataType : 'json', //接受数据格式 
		async : false,
		success : function(json) {
		},
		error : function() {
			layer.msg("系统错误,请联系管理员");
		}
	});	
}
</script>
</head>
<style type="text/css">
.ban_a, .yue_a{margin:0px;padding: 3px 15px 6px;bottom: 20px;left: 90px;position: absolute;}
iframe{height: 90%;}
.ban_content,.yue_content{position: relative;}
</style>
<body>
<div class="main">
	<div class="read_content_11">
		<!--阅   办 模块 -->
		<div class="read_content">
		    <div class="ban_content" id="readContent">
		    	<div class="ban_div">办</div>
		    	<c:if test="${needHandle eq '1'}">
		    		<c:forEach var="needHandles" items="${needHandleList}"  varStatus="status">
		    			<c:if test="${status.index < 2}">
		        			<a href="javascript:;" onclick="toMessageDetail('${needHandles.messageUrl}','${needHandles.messageId}','${needHandles.parentModelName}');">
			        			<p class="ban_p">
			        				<span style="overflow: hidden;width: 225px;display: inline-block;text-overflow:ellipsis;white-space: nowrap;" title="${status.index+1}&nbsp;&nbsp;${needHandles.messageContent}">${status.index+1}&nbsp;&nbsp;${needHandles.messageContent}</span>
			        			</p>
		        			</a>
		        		</c:if>	 
		        	</c:forEach>	
		        	<a id="todo" class="ban_a" href="javascript:;">立即处理 (${needHandleCount})</a>
		        </c:if>	
		        <c:if test="${needHandle eq '0'}">
		        	<p class="ban_p" style="position: relative;">
		    			<span style="position: absolute;top: 40px;left: 50px;font-size:18px">暂无消息</span>
		    		</p>
		        </c:if>
		    </div>
		 	<div class="yue_content">
		    	<div class="yue_div">阅</div>
		    	<c:if test="${needRead eq '1'}">
		        	<c:forEach var="needReads" items="${needReadList}"  varStatus="status">
		        	     <c:if test="${status.index < 2}">
		        		 	<p class="ban_p"><span style="overflow: hidden;width: 225px;display: inline-block;text-overflow:ellipsis;white-space: nowrap;" title="${status.index+1}&nbsp;&nbsp;${needReads.messageContent}">${status.index+1}&nbsp;&nbsp;${needReads.messageContent}</span></p>
		        		 </c:if>  
		        	</c:forEach>	
		        	<a id="pending_items" class="yue_a" href="javascript:;">立即处理 (${needReadCount})</a>
		        </c:if>	
		        <c:if test="${needRead eq '0'}">
		        	<p class="ban_p" style="position: relative;">
		    			<span style="position: absolute;top: 40px;left: 50px;font-size:18px">暂无消息</span>
		    		</p>
		        </c:if>
		  	</div>
		 </div>
	</div>
	<div class="page_tit mtmb20" style="width:100%">
       	  <span>我的任务列表</span>
	</div>  
	<ul id="ul" class="nav_ul ofo">
      <li style="width:8%;margin-left:1%;" id = "projectInfoLi" name='menu_a' class='navicon_on_a'><a id='icon1_b' href="${_baseUrl}/myWorkbench/showKDWorkRead" target='contIframe_a'>文档管理</a></li>
      <li style="width:8%" name='menu_a'><a href="${_baseUrl}/myWorkbench/showKTWorkRead" target='contIframe_a'>测试管理</a></li>
      <li style="width:8%" name='menu_a'><a href="${_baseUrl}/myWorkbench/showDemandWorkRead" target='contIframe_a'>需求管理</a></li>
      <li style="width:75%"></li>
    </ul>
	<div id='iframeCont' class='iframeCont' style="height: 520px;">
	   <iframe name='contIframe_a'  class='contIframe' frameborder='0' width='100%' height='90%' frameborder="none" scrolling="auto"></iframe>
	</div> 
</div>
</body>
<script type='text/javascript'>
	 window.onload = function(){
		 setAuto();
		 navStatus();
     }
// =============================================
function navStatus(){
  var oNav = $(".nav_ul li[name='menu_a']"),
          oIfr = $('.contIframe');
  document.getElementById('icon1_b').click();
  oNav.each(function(){
    $(this).click(function(){
      $(this).removeClass("navicon_on_a").addClass("navicon_on_a");
      oNav.not($(this)).removeClass('navicon_on_a');
    });
  });
};
	// 设置自适应
	function setAuto(){
		var initwidth = document.documentElement.clientWidth;
		if(initwidth >= '1680'){
			$('html').css('font-size','100%');
		}else if(initwidth >= '1025'){
			$('html').css('font-size','90%');
		}else {
			$('html').css('font-size','80%');
		}
	}
	$(function(){
        $("#todo").click(function() {
        layerIndex = layer.open({
                type: 2 //Page层类型
                ,area: ['900px', '400px']
                ,title: '我的工作台--待办事项'
                ,shade: 0.6 //遮罩透明度
                ,maxmin: true //允许全屏最小化
                ,anim: false //0-6的动画形式，-1不开启
                ,content: '${_baseUrl}/myWorkbench/showNeedHandleEvent?work=1',
                success: function () {
                	document.onkeydown = function (e) { // 回车提交表单
    				    var theEvent = window.event || e;
    				    var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
    				    if (code == 13) {
    				    	 $(this).trigger("click");
    							return false
    				    }
    				} 
                },
                end: function () {
                    location.reload();
                }
            });
        layer.full(layerIndex);
        });
        if(jumpWork == "Workbench"){
			layerIndex = layer.open({
                type: 2 //Page层类型
                ,area: ['900px', '400px']
                ,title: '我的工作台--待办事项'
                ,shade: 0.6 //遮罩透明度
                ,maxmin: true //允许全屏最小化
                ,anim: false //0-6的动画形式，-1不开启
                ,content: '${_baseUrl}/myWorkbench/showNeedHandleEvent',
                end: function () {
                    location.reload();
                }
            });
			layer.full(layerIndex);
		}else if(jumpWork == ''){
			//parent.$("#ban_yue").hide();
		}
        $("#pending_items").click(function() {
            layerIndex = layer.open({
                    type: 2 //Page层类型
                    ,area: ['900px', '400px']
                    ,title: '我的工作台--待阅事项'
                    ,shade: 0.6 //遮罩透明度
                    ,maxmin: true //允许全屏最小化
                    ,anim: false //0-6的动画形式，-1不开启
                    ,content: '${_baseUrl}/myWorkbench/showNeedReadEvent',
                    end: function () {
                    	location.reload();
                        }
            });
            layer.full(layerIndex);
        });
  
    });
</script>
</html>